﻿using System;
using System.Globalization;
using System.Text;
using System.Windows.Data;

namespace Poet.Converters
{
    public class CharArrayToStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var charArray = value as char[];
            if (charArray == null) return null;
            var stringBuilder = new StringBuilder();
            foreach (var item in charArray)
            {
                stringBuilder.Append(", ( ");
                stringBuilder.Append(item);
                stringBuilder.Append(" )");
            }

            return stringBuilder.ToString(2, stringBuilder.Length - 2);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
